<template>
	<view>
		<u-select v-model="show" :list="list" @confirm="confirm"></u-select>
	</view>
</template>

<script>
	import {
	  xiaohaoJifen
	} from '../../../haoduogeni/common/api/user';
	export default {
		data() {
			return {
				show: false,
				list: [],
			}
		},
		created() {
			this.getList();
		},
		methods: {
			getList(){
			      var _this = this;
			      xiaohaoJifen().then(res => {
			        //成功时回调函数
			        console.log(res, '获取生成图片消耗积分')
			        if (res.errno == 0) {
			          const data = res.data.hangye; // 假设返回的是数组格式数据
					  const transformedArray = data.map((item, index) => ({
					    value: index + 1, // 例如 "category_1"
					    label: item
					  }));
			          this.list = transformedArray;
			
			        }
			      }).catch(err => {
			        //失败时回调函数
			        console.log(err)
			      })
			      
			},
			open() {
				this.show = true;
			},
			confirm(e){
				console.log(e,'confirm')
				this.$emit('confirm',e[0])
			}
		}
	}
</script>

<style>

</style>